home *** CD-ROM | disk | FTP | other *** search
/ 17 Bit Software 6: Level 6 / 17 Bit - Level 6 (1998)(Epic Marketing)[!].iso / quartz / q0429.dms / q0429.adf / etc / rsconvert / main.c < prev    next >
C/C++ Source or Header  |  1992-05-20  |  2KB  |  95 lines

  1. /*
  2.  * main.c
  3.  *
  4.  * Copyright (C) 1989, 1991, Craig E. Kolb
  5.  * All rights reserved.
  6.  *
  7.  * This software may be freely copied, modified, and redistributed
  8.  * provided that this copyright notice is preserved on all copies.
  9.  *
  10.  * You may not distribute this software, in whole or in part, as part of
  11.  * any commercial product without the express consent of the authors.
  12.  *
  13.  * There is no warranty or other guarantee of fitness of this software
  14.  * for any purpose.  It is provided solely "as is".
  15.  *
  16.  * $Id: main.c,v 4.0.1.1 91/11/26 21:11:33 cek Exp Locker: cek $
  17.  *
  18.  * $Log:    main.c,v $
  19.  * Revision 4.0.1.1  91/11/26  21:11:33  cek
  20.  * patch3: Define ENDCAPS for cylinder-capping.
  21.  * 
  22.  * Revision 4.0  91/07/17  14:29:30  kolb
  23.  * Initial version.
  24.  * 
  25.  */
  26. #include <stdio.h>
  27. #ifdef SYSV
  28. #include <memory.h>
  29. #endif
  30. #include "libcommon/common.h"
  31.  
  32. extern FILE *yyin;
  33.  
  34. #define usage(v)        fprintf(stderr,"usage: %s [oldfile]\n",v)
  35.  
  36. main(argc, argv)
  37. int argc;
  38. char **argv;
  39. {
  40.     if (argc > 2) {
  41.         usage(argv[0]);
  42.         exit(1);
  43.     }
  44.  
  45.     if (argc == 2) {
  46.         yyin = fopen(argv[1], "r");
  47.         if (yyin == (FILE *)NULL) {
  48.             fprintf(stderr,"Cannot open %s\n",argv[1]);
  49.             exit(2);
  50.         }
  51.     } else
  52.         yyin = stdin;
  53.     printf("/* Converted by rsconvert */\n");
  54.     printf("#define ENDCAPS\n");
  55.     yyparse();
  56. }    
  57.  
  58. char *
  59. strsave(s)
  60. char *s;
  61. {
  62.     extern voidstar Malloc();
  63.     char *r;
  64.  
  65.     r = (char *)Malloc(strlen(s) + 1);
  66.     strcpy(r, s);
  67.     return r;
  68. }
  69.  
  70. voidstar
  71. Malloc(n)
  72. unsigned n;
  73. {
  74.     voidstar r;
  75.     extern voidstar malloc();
  76.  
  77.     r = malloc(n);
  78.     if (r == (voidstar)NULL) {
  79.         fprintf(stderr,"Out of memory allocating %d bytes.\n");
  80.         exit(1);
  81.     }
  82.     return r;
  83. }
  84.  
  85. voidstar
  86. Calloc(nelem, elen)
  87. unsigned nelem, elen;
  88. {
  89.     voidstar res;
  90.  
  91.     res = Malloc(nelem*elen);
  92.     bzero(res, (int)nelem*elen);
  93.     return res;
  94. }
  95.